package v2ch4.ExecSQL;

import java.io.File;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Properties;

public class PropertyReader{
    private static final String sFileName = "database.properties";
    private static String sDirSeparator = System.getProperty("file.separator");
    private static Properties props = new Properties();
    private static FileInputStream ins = null;

    public static Properties getProps() throws IOException {
        File currentDir = new File(".");
        try {
            String sFilePath = currentDir.getCanonicalPath() + sDirSeparator + sFileName;
            ins = new FileInputStream(sFilePath);
            props.load(ins);
             //System.out.println(props.getProperty("jdbc.drivers"));
            return props;
        }
        catch (FileNotFoundException e) {
            System.out.println("File not found!");
            e.printStackTrace();
            throw new IOException();
        }
        catch (IOException e) {
            System.out.println("IO Error!");
            e.printStackTrace();
            throw new IOException();

        } finally {
            try {
                if (ins != null) {
                    ins.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}

